//
//  getFilenameHD.m
//  phosphon.de
//
//  Created by Dirk Lieder
//  Copyright 2011 phosphon. All rights reserved.
//

#import "getFilenameHD.h"

@implementation PHOSPHON

// get Filename with path
+(NSString *)imagePostfix:(NSString *)inName{
    
    NSMutableString *loadImage;
    NSString *path;
    
    loadImage =[[inName stringByReplacingOccurrencesOfString:@" " withString:@"-"] mutableCopy];

    // handle retina
    BOOL hasHighResScreen = NO;
    if ([UIScreen instancesRespondToSelector:@selector(scale)]) {
        CGFloat scale = [[UIScreen mainScreen] scale];
        if (scale > 1.0) {
            hasHighResScreen = YES;
        }
    }


    if(hasHighResScreen){
        path = [[NSBundle mainBundle] pathForResource:[loadImage stringByAppendingString:@"@2x"] ofType:@"jpg"]; 
    } else {
        path = [[NSBundle mainBundle] pathForResource:loadImage ofType:@"jpg"]; 
    }

    return path;
}

// get Filename
+(NSString *)imagePost:(NSString *)inName imagePostfix:(NSString *)imagePostfix{
    
    NSMutableString *loadImage;
    NSString *substring;
    NSString *HD = @"";
        
    loadImage =[[inName stringByReplacingOccurrencesOfString:@" " withString:@"-"] mutableCopy];

    if([loadImage hasSuffix:@".tif"]){
        substring = [[[[loadImage substringToIndex:[loadImage length]-4] stringByAppendingString:imagePostfix] stringByAppendingString:HD]stringByAppendingString:@".jpg"];
    } else {
        substring = [[[loadImage stringByAppendingString:imagePostfix] stringByAppendingString:HD] stringByAppendingString:@".jpg"];
    }
    
    return substring;
}


@end
